package com.zs.toolbox.web2j.system.core.controller.common;


import com.zs.toolbox.web2j.common.response.WtBaseResponse;
import com.zs.toolbox.web2j.common.web.WtBaseController;
import com.zs.toolbox.web2j.system.core.entity.WtDictionaryItemEntity;
import com.zs.toolbox.web2j.system.core.request.WtDictListReqeust;
import com.zs.toolbox.web2j.system.core.service.WtDictionaryItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 字典类型表 前端控制器
 * </p>
 *
 * @author eric.zhang
 * @since 2018-10-08
 */
@RestController
@Api("公共字典查询接口")
@RequestMapping("/api/v1/common/dict")
public class WtCommonDictionaryController extends WtBaseController {

    @Autowired
    WtDictionaryItemService wtDictionaryItemService;

    @PostMapping("list")
    @GetMapping("list")
    @ApiOperation("根据字典类型获得字典列表")
    public WtBaseResponse<List<WtDictionaryItemEntity>> getDictByType(@RequestBody WtDictListReqeust reqeust) {
        this.volidate(reqeust);
        List<WtDictionaryItemEntity> list  = wtDictionaryItemService.listByTypeId(reqeust.getTypeId());
        return new WtBaseResponse(list);
    }

}
